<?php

namespace App\Repositories\Address;

use Prettus\Repository\Eloquent\BaseRepository;
use Prettus\Repository\Criteria\RequestCriteria;
use App\Repositories\Address\DeliverRegionCoordinatesRepository;
use App\Models\Address\DeliverRegionCoordinates;

/**
 * Class DeliverRegionCoordinatesRepositoryEloquent
 * @package namespace App\Repositories\Address;
 */
class DeliverRegionCoordinatesRepositoryEloquent extends BaseRepository implements DeliverRegionCoordinatesRepository
{
    /**
     * Specify Model class name
     *
     * @return string
     */
    public function model()
    {
        return DeliverRegionCoordinates::class;
    }

    /**
     * 获取所有配送区域的坐标信息
     * @return mixed
     */
    public function getAllRegionCoordinates(){
        return $this->all();
    }

    /**
     * 根据配送区域，获取单个配送区域的坐标信息
     * @param int $id
     * @return mixed
     */
    public function getRegionCoordinatesByRegionId(int $id){
        return $this->findWhere(['rid'=>$id]);
    }
    /**
     * Boot up the repository, pushing criteria
     */
    public function boot()
    {
        $this->pushCriteria(app(RequestCriteria::class));
    }
}
